/**'clerk.filter',
 * Created by 黄忠园 on 2017/8/24.
 */
angular.module('unmannemall', [
        'ui.router',//路由
        'ngAnimate',//动画
        'ngCookies',//cookie
        'ng.comfirm',//全局comfirm确认框
        'module.scan',
        'directive',
        'ngTouch',
        'module.menu',
        'module.order',
        'module.auth',
        'module.wxauth',
        'module.coupon',
        'service.cupboarlock',
        'module.lock',
        'module.paysuccess',
        'module.friendly',
        'service.imsdk',
    ])
    .run(
        ['$rootScope', '$state', '$stateParams','WxjssdkService',
            function ($rootScope, $state, $stateParams,WxjssdkService) {
                $rootScope.$state = $state;
                $rootScope.$stateParams = $stateParams;
                $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState) {
                    /*首页不返回登录页*/
                    if(toState.name == "scan" && fromState.name != ''){
                        event.preventDefault();
                    }
                });
                var url = window.location.href;
                var trueurl = url;
                if (url.indexOf("#") > 0) {
                    trueurl = url.substring(0, url.indexOf("#"));
                }
                WxjssdkService.setSpaUrl(trueurl);
            }
        ]
    )

    .config(
        ['$stateProvider', '$urlRouterProvider', '$locationProvider', '$httpProvider',
            function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) {
                //正式环境
                $urlRouterProvider.otherwise('/lock?lock_appid=wxd58951ae0414cb55&shopid=476429753');
                //$urlRouterProvider.otherwise('/friendlylink');
                //测试环境
                //$urlRouterProvider.otherwise('/lock?lock_appid=wxd58951ae0414cb55&shopid=663727486');
                //$urlRouterProvider.otherwise('/lock?appid=wxd58951ae0414cb55&shopid=977534855');
                $locationProvider.html5Mode(html5mode);
                $httpProvider.defaults.withCredentials = true;//跨域问题解决
            }
        ]);